#ifndef _D3DCLASS_H_
#define _D3DCLASS_H_

#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib")
#pragma comment(lib, "d3dx10.lib")


#include <dxgi.h>
#include <d3dcommon.h>
#include <d3d11.h>
#include <d3dx10math.h>

enum RENDERTYPES
{
	RENDERTYPE_SOLID = 0,
	RENDERTYPE_WIREFRAME = 1
};

static const float	SCREEN_DEPTH	= 1000.0f;
static const float	SCREEN_NEAR		= 1.0f;

class D3DClass
{
public:
	D3DClass();

	bool Initialize(int, int, bool, HWND, bool, float, float);
	void Shutdown();
	
	void BeginScene(float, float, float, float);
	void EndScene();

	ID3D11Device*			GetDevice();
	ID3D11DeviceContext*	GetDeviceContext();

	void GetProjectionMatrix(D3DXMATRIX&);
	void GetWorldMatrix(D3DXMATRIX&);
	void GetOrthoMatrix(D3DXMATRIX&);

	void GetVideoCardInfo(char*, int&);

	void SetRenderWireframe()	{ m_deviceContext->RSSetState(m_rasterStateWireframe); m_rendertype = true; };
	void SetRenderSolid()		{ m_deviceContext->RSSetState(m_rasterStateSolid); m_rendertype = false; };

	short int GetRenderType() const { return m_rendertype; }

	void SetActiveRenderTarget(ID3D11RenderTargetView* i_rt)
	{ 
		ID3D11RenderTargetView* rt = i_rt;
		m_deviceContext->OMSetRenderTargets(1, &rt, m_depthStencilView);
	};

	void SetBackBufferRenderTarget();
	void ResetViewport();

	void TurnZBufferOn();
	void TurnZBufferOff();

private:
	bool	m_vsync_enabled;
	short int	m_rendertype;
	int		m_videoCardMemory;
	char	m_videoCardDescription[128];

	IDXGISwapChain*			m_swapChain;
	ID3D11Device*			m_device;
	ID3D11DeviceContext*	m_deviceContext;
	
	ID3D11RenderTargetView* m_renderTargetView;
	
	ID3D11Texture2D*			m_depthStencilBuffer;
	ID3D11DepthStencilState*	m_depthStencilState;
	ID3D11DepthStencilView*		m_depthStencilView;
	ID3D11RasterizerState*		m_rasterStateSolid;
	ID3D11RasterizerState*		m_rasterStateWireframe;
	D3D11_VIEWPORT				m_viewport;
	ID3D11DepthStencilState*	m_depthDisabledStencilState;
	D3DXMATRIX m_projectionMatrix;
	D3DXMATRIX m_worldMatrix;
	D3DXMATRIX m_orthoMatrix;
};

#endif